package BM;

/**
 * @author konley
 * @date 2021-12-11 11:48
 */
public class Test {
    public static void main(String[] args) throws Exception {
        SenderA senderA = new SenderA();
        ReceiverB receiverB = new ReceiverB();
        //B生成密钥对
        receiverB.getKey();
        //取得B的公钥
        String puk = receiverB.getPukKey();
        //发送方A用B的公钥对明文M进行加密得到密文Y
        String y = senderA.send(puk);
        System.out.println("------------------------------------");
        System.out.println("A向B发送加密消息...");
        System.out.println("密文为："+y);
        System.out.println("------------------------------------");
        //接收方B对A的密文使用自己的私钥进行解密
        String m = receiverB.decrypt(y);
        System.out.println("B对A的密文进行解密...");
        System.out.println("解密成功，明文为："+m);
    }
}
